# name : surv.event.power.fun events|power, ttenevent
# key: surv.event.power.fun
# contributor: Shuguang Sun
# --
${1:ttenevent} <- function(x) {
  hr0 <- 1
  c <- sqrt(x$ratio)/(1 + x$ratio)
  delta <- -c * (log(x$hr) - log(hr0))
  zalpha <- qnorm(1 - x$alpha/x$sided)
  zb <- qnorm(1- x$beta)
  nevents <- (zalpha + zb)^2 / delta^2
  nevents
}
$1(x)